package top.jojoace.JPA.VO;

import com.github.dozermapper.core.DozerBeanMapperBuilder;
import com.github.dozermapper.core.Mapper;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
import java.util.List;

public class PagingDozer<T,K> extends Paging {

    @SuppressWarnings("unchecked")//去除 作为原始类型 'Paging' 的成员对 'initPageParameters(Page<T>)' 的未检查的调用 的警告
    public PagingDozer(Page<T> pageT,Class<K> classK){
        this.initPageParameters(pageT);

        List<T> restList = pageT.getContent();
        Mapper mapper = DozerBeanMapperBuilder.buildDefault();
        List<K> voList  =new ArrayList<>();

        restList.forEach(t->{
            K vo = mapper.map(t,classK);
        });
        this.setItems(voList);
    }
}
